import { Body, Controller, Inject, Post } from "@midwayjs/core";
import { RespInfo } from "../types/common.type";
import { NoteService } from "../service/note.service";


@Controller('/note')
export class NoteController {

  @Inject()
  noteService: NoteService;


  @Post('/add')
  async add(@Body() info: { user: string, remark: string, bgcolor: string }): Promise<RespInfo> {
    const { user, remark, bgcolor } = info;
    return await this.noteService.add(user, remark, bgcolor)
  }

  @Post('/delete')
  async delete(@Body() info: { uid: string }): Promise<RespInfo> {
    const { uid } = info;
    return await this.noteService.delete(uid)
  }

  @Post('/list')
  async list(@Body() info: { page: number, number: number, user?: string }): Promise<RespInfo> {
    const { page, number, user } = info;
    return await this.noteService.list(page, number, user)
  }

  @Post('/get')
  async get(@Body() info: { uid: string, user?: string }): Promise<RespInfo> {
    const { uid, user } = info;
    return await this.noteService.get(uid, user)
  }

  @Post('/share')
  async share(@Body() info: { uid: string }): Promise<RespInfo> {
    const { uid } = info;
    return await this.noteService.share(uid)
  }

}